package org.fatmansoft.teach.repository;

import org.fatmansoft.teach.models.DailyActivity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface DailyActivityRepository extends JpaRepository<DailyActivity, Integer> {

    //用于主键自增
    @Query(value = "select max(dailyActivityId) from DailyActivity ")
    Integer getMaxId();

    @Query(value = "from DailyActivity where ?1='' or activityName like %?1% or activityType like %?1%")
    List<DailyActivity> findDailyListByNameType(String nameType);

    Optional<DailyActivity> findByActivityName(String activityName);

    void deleteByActivityName(String name);
}
